package com.mydemo.design_pattern.action_type.chain_responsibility_pattern;

/**
 * <p></p >
 *
 * @author liming1
 * @version $Id: AbstractLoggerHandler, v1.0 2019-09-19 14:25 liming1 Exp $
 */
public abstract class AbstractLoggerHandler {

    public static final int INFO = 1;
    public static final int WARN = 2;
    public static final int ERROR = 3;

    protected int level;

    public AbstractLoggerHandler nextHandler;

    public void setNextHandler(AbstractLoggerHandler nextHandler) {
        this.nextHandler = nextHandler;
    }

    public void print(int l, String msg) {
        if (l == this.level) {
            System.out.println(this.getClass().getSimpleName() + "类上执行了：" + msg);
        } else {
            if (nextHandler != null) {
                nextHandler.print(l, msg);
            }
        }
    }
}
